@extends('admin::layouts.master')
@section('title')
    结算手续费率
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <ul class="layui-tab-title">
                        @foreach($arr_tab as $key=>$value)
                            @if($key == $s_tab_type)
                                <li data-type="{{$key}}" class="layui-this">{{$value}}</li>
                            @else
                                <li data-type="{{$key}}">{{$value}}</li>
                            @endif
                        @endforeach
                    </ul>
                    <div class="layui-card-body ">


                        <div class="layui-row">
                            <form class="layui-form" lay-filter="form_edit" >

                                @switch($s_tab_type)
                                    @case('jsfl')
                                    <div class="layui-card-header">结算手续费率<span class="x-red">（ * 费率单位是千分之几，请填写整数。如：千分之六，填6）</span></div>
                                    <div class="layui-form-item x-city">

                                        <label class="layui-form-label"><span class="x-red">*</span>结算手续费率</label>
                                        <div class="layui-input-inline">
                                            <input type="number" name="settle_service_fee_rate" lay-verify="required|number" placeholder="请输入结算手续费率" class="layui-input">
                                        </div>
                                    </div>
                                    @break

                                    @case('join_subheading')
                                    <div class="layui-card-header">商户加盟时，选择店铺类型解释</div>

                                    <div class="layui-form-item x-city">
                                        <label class="layui-form-label">维修店副标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" maxlength="50" name="shop_joinin_wx_content" placeholder="请输入维修店副标题" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-form-item x-city">
                                        <label class="layui-form-label">检测机构副标题</label>
                                        <div class="layui-input-inline">
                                            <input type="text" maxlength="50" name="shop_joinin_jc_content" placeholder="请输入检测机构副标题" class="layui-input">
                                        </div>
                                    </div>
                                        @break

                                    @default
                                @endswitch


                                <div class="layui-form-item">
                                    <label for="L_repass" class="layui-form-label"></label>
                                    <button class="layui-btn" lay-filter="but_save" lay-submit="">设置</button>
                                </div>

                            </form>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>

@endsection

@section('tab_js')

    <script>
        $(document).on('click', '.layui-tab-title li', function () {
            var tab_type = $(this).attr('data-type');
            var data = '?tab_type='+tab_type;
            location_redirect('admin_config_private_set'+data);
        });
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
            layer = layui.layer;
            //监听提交
            form.on('submit(but_save)', function (data) {
            	layer.confirm("确认要修改吗", function(index){

            	    var form_data = data.field;
                    form_data.action = 'do';
                    if(form_data.settle_service_fee_rate < 0){
                        layer.msg("结算手续费率不能小于0");
                        return false;
                    }
	                $.ajax({
	                    url: js_url('admin_config_private_set'),
	                    type: 'get',
	                    data: form_data,
	                    dataType: "json",
	                    success: function (result) {
	                        if (result.state === 0) {
	                            layer.msg("更新成功", {time: 500, icon: 6}, function () {
	                                //关闭当前frame
	                                xadmin.close();
	                                // 可以对父窗口进行刷新
	                                xadmin.father_reload();
	                            });
	                        } else {
	                            layer.msg(result.msg, {time: 500, icon: 5});
	                        }
	                    }
	                });
	            })
                return false;
            });

            /*表单赋值*/
            form.val('form_edit', {
                "settle_service_fee_rate": '{{$data['settle_service_fee_rate']}}',
                "shop_joinin_wx_content": '{{$data['shop_joinin_wx_content']}}',
                "shop_joinin_jc_content": '{{$data['shop_joinin_jc_content']}}',
            })
            
        });
    </script>
@endsection